{extend name="layout/iframe" /}

{block name="pagecss"}
<link href="__STATIC__/plugins/layui-formSelects/formSelects-v4.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" checked="" lay-skin="switch" lay-text="启用|禁用"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>启用</em><i></i></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>购买商品</label>
            <div class="layui-input-block">
                <input type="hidden" class="layui-input product_id buy_product_id" name="buy_product_id" value="" data-value="" lay-verify="buy_product_id">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid select-products" data-type="buy" style="float: right;">选择商品</button>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>赠送商品</label>
            <div class="layui-input-block">
                <input type="hidden" class="layui-input product_id gift_product_id" name="gift_product_id" value="" lay-verify="gift_product_id">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid select-products" data-type="gift" style="float: right;">选择赠品</button>
            </div>
        </div>
        <!--<div class="layui-form-item layui-form-text buy_limit_num-div">
            <label class="layui-form-label"><span class="required">*</span>买赠数量</label>
            <div class="layui-input-block">
                <input type="number" class="layui-input" name="" maxlength="10" lay-verify="" placeholder="" autocomplete="off">
            </div>
        </div>-->
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="required">*</span>买</label>
                <div class="layui-input-block">
                    <input type="number" class="layui-input" name="buy_num" value="" maxlength="10" lay-verify="buy_num" placeholder="" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label"><span class="required">*</span>赠</label>
                <div class="layui-input-block">
                    <input type="number" class="layui-input" name="gift_num" value="" maxlength="10" lay-verify="gift_num" placeholder="" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>面向用户</label>
            <div class="layui-input-block to_user_type" data-value="">
                <input type="radio" name="to_user_type" value="1" title="全部用户" lay-filter="to_user_type" checked="">
                <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>全部用户</div></div>
                <input type="radio" name="to_user_type" value="2" title="新用户" lay-filter="to_user_type">
                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>新用户</div></div>
                <input type="radio" name="to_user_type" value="3" title="会员" lay-filter="to_user_type">
                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>会员</div></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text user_ids-div" style="display: none;">
            <label class="layui-form-label"><span class="required">*</span>选择会员</label>
            <div class="layui-input-block">
                <select name="to_users" id="memberlevelIds" xm-select="memberlevelIds" lay-verify="to_users">
                    {foreach name="memberlevelList" item="memberlevel" key="memberlevelKey"}
                        <option value="{$memberlevel.id}">{$memberlevel.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>适用范围</label>
            <div class="layui-input-block range" data-value="">
                <input type="radio" name="range" value="1" title="全部门店" lay-filter="range" checked="">
                <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon"></i><div>全部门店</div></div>
                <input type="radio" name="range" value="2" title="线上商城" lay-filter="range">
                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>线上商城</div></div>
                <input type="radio" name="range" value="3" title="线下门店" lay-filter="range">
                <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i><div>线下门店</div></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text store_ids-div" style="display: none;">
            <label class="layui-form-label"><span class="required">*</span>选择门店</label>
            <div class="layui-input-block">
                <select name="store_ids" id="storeIds" xm-select="storeIds" lay-verify="store_ids">
                    {foreach name="storeList" item="store" key="storeKey"}
                        <option value="{$store.id}">{$store.name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <input type="hidden" name="id" value="">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
<input type="hidden" class="check_buy_product_url" value="{:url('admin/'.strtolower($model).'/checkBuyProduct')}">

<input type="hidden" class="select_products_url" value="{:url('admin/buygifts/selectproducts')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/pages/js/buygifts.js" type="text/javascript"></script>
{/block}